﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HCMServices.DAO;
using HCMServices.DTO;
using System.Collections.Generic;

namespace HCMServices.Tests.TESTDAO
{
    /// <summary>
    /// Unit test for StreetDAO class
    /// </summary>
    [TestClass]
    public class TestStreetDAO
    {
        /// <summary>
        /// Unit test for Search() method in StreetDAO class
        /// </summary>
        [TestMethod]
        public void TestSearch()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            StreetDAO streetDAO = new StreetDAO(connectString);
            StreetDTO streetDTO = null;
            streetDTO = streetDAO.Search(701);
            if (streetDTO != null && streetDTO.Id == 701 && streetDTO.Name == "3 Tháng 2")
            {
                Assert.IsTrue(true);
                return;
            }

            Assert.IsFalse(true);
        }

        /// <summary>
        /// Unit test for GetAllDuongDTO() method in StreetDAO class
        /// </summary>
        [TestMethod]
        public void TestGetAllDuongDTO()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            StreetDAO streetDao = new StreetDAO(connectString);
            List<StreetDTO> listStreetDTO = null;
            listStreetDTO = streetDao.GetAllDuongDTO();
            if (listStreetDTO == null || listStreetDTO.Count == 0)
            {
                Assert.IsFalse(true);
            }

            foreach (StreetDTO street in listStreetDTO)
            {
                if (street.Name == "3 Tháng 2")
                {
                    if (street.Id != 701)
                    {
                        Assert.IsFalse(true);
                    }
                }
            }

            Assert.IsTrue(true);
        }

        /// <summary>
        /// Unit test for TestGetIdByName() method in StreetDAO class
        /// </summary>
        [TestMethod]
        public void TestGetIdByName()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            StreetDAO streetDao = new StreetDAO(connectString);
            int id = streetDao.GetIdByName("3 Tháng 2");
            if (id == 701)
            {
                Assert.IsTrue(true);
                return;
            }

            Assert.IsFalse(true);
        }
    }
}
